package com.soft.bams.entity;

/**
 * @author wangshaoshuai
 * @desc TODO
 * @date 2025/4/21
 */
public class CreditAccount extends Account {


    private double ceiling;

    public double getCeiling() {
        return ceiling;
    }

    public void setCeiling(double ceiling) {
        this.ceiling = ceiling;
    }

    public CreditAccount() {

    }

    public CreditAccount(String password, String name, String personId, String email, double balance, double ceiling) {
        super(password, name, personId, email, balance);
        this.ceiling = ceiling;
    }

    public CreditAccount(Long id, String password, String name, String personId, String email, double balance, double ceiling) {
        super(id, password, name, personId, email, balance);
        this.ceiling = ceiling;
    }


    @Override
    public Account withdraw(double money) {
        if(this.getBalance()+ceiling>=money){
            if(this.getBalance()>=money){
                this.setBalance(this.getBalance() - money);
            }else{
                this.ceiling-=money-this.getBalance();
                this.setBalance(0.0);
            }
            return this;
        }
        System.out.println("银行卡余额不足");
        return this;
    }

    @Override
    public String toString() {
        return "CreditAccount{" +
                "ceiling=" + ceiling +
                "} " + super.toString();
    }
}
